<template>
    <view>
        <!-- components/goods/index.wxml -->
        <!-- 列表 -->
        <view class="list">
            <view class="list-info" @tap="goodsDetail($event, { goods_id: item.goods_id })" :data-goods_id="item.goods_id" v-for="(item, index) in goodsList" :key="index">
                <view class="list-info-img" :id="'list-info-img' + index">
                    <image :src="item.goods_img + '?x-oss-process=image/resize,w_320'" mode="aspectFill" :data-index="index"></image>
                </view>

                <view class="list-info-detail">
                    <view class="list-info-detail-title">
                        {{ item.goods_title }}
                    </view>
                    <view class="detail-tip" v-if="item.goods_tag.length > 0">
                        <view class="tip-span" v-for="(item, index1) in item.goods_tag" :key="index1">{{ item }}</view>
                        <view class="clear"></view>
                    </view>
                    <view>
                        <view class="list-info-detail-price">
                            <view class="list-info-detail-price-discounts">
                                <span>¥</span>
                                {{ item.goods_min_price }}
                            </view>
                            <view class="list-info-detail-price-original">¥{{ item.goods_max_price }}</view>
                        </view>
                    </view>
                </view>
            </view>
        </view>
        <view class="list-end" v-if="isEnd == 'end'">已经到底啦</view>
    </view>
</template>

<script>
// components/goods/index.js
const Config = require('../../config/index.js');

export default {
    data() {
        return {
            imgUrl: Config.imgUrl //图片url
        };
    },
    /**
     * 组件的属性列表
     */
    props: {
        goodsList: {
            // 商品数据
            type: Array,
            default: () => []
        },
        //数据是否加载完成
        isEnd: {
            type: String,
            default: 'start'
        }
    },
    /**
     * 组件的方法列表
     */
    methods: {
        goodsDetail(e, _dataset) {
            
            if (!e.currentTarget) {
                if (_dataSet.tagId) {
                    e.currentTarget = {
                        id: _dataSet.tagId
                    };
                } else {
                    e.currentTarget = {
                        dataset: _dataSet
                    };
                }
            }
            
            // 商品详情
            uni.navigateTo({
                url: '/pages/goodsDetail/index?id=' + e.currentTarget.dataset.goods_id
            });
        }
    }
};
</script>
<style>
@import './index.css';
</style>
